<?php
namespace Admin\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function index(){
        $this->display();

    }
    

   
    public function add(){
        
        if(empty($_POST['title']) || empty($_POST['content'])){
            $this->error("不能为空");
            exit;
        }
        $blogs = M('blogs');//实例化blogs表
        $blogs->create();//自动完成
        $blogs->pubtime = time();//添加发布时间
        $blogs->ip = $_SERVER['REMOTE_ADDR'];
        if($blogs->add()){
            $this->display('index');
        }else{
            exit($blogs->getError());
        }
    }
}